package cn.xd.itstack.springframework.aop.framework;

import cn.xd.itstack.springframework.aop.AdvisedSupport;

import java.sql.PreparedStatement;

/**
 * @Classname ProxyFactory
 * @Description TODO
 * @Date 2022/6/6 下午7:22
 * @Created by lvxiaodong
 */
public class ProxyFactory {


    private AdvisedSupport advisedSupport;

    public ProxyFactory(AdvisedSupport advisedSupport){
        this.advisedSupport = advisedSupport;
    }


    public Object getProxy(){
      return  createAopProxy().getProxy();
    }

    private AopProxy createAopProxy() {
        if(advisedSupport.isProxyTargetClass()){
            return new CglibAopProxy(advisedSupport);
        }
        return new JdkDynamicAopProxy(advisedSupport);
    }


}
